package com.ffyc.resale.web;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ffyc.resale.model.*;
import com.ffyc.resale.service.AdminService;
import com.ffyc.resale.service.GoodsService;
import com.ffyc.resale.service.UserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/admin")
public class AdminController {
    @Autowired
    AdminService adminService;

    @GetMapping("/profile")
    public Result profile(@RequestHeader String adminToken){
        Admin admin = adminService.profile(adminToken);
        return new Result(200,"获取成功",admin);
    }
    @PostMapping("/updateProfile")
    public Result updateProfile(@RequestHeader String adminToken,@RequestBody Admin admin){
        adminService.updateProfile(adminToken,admin);
        return new Result(200,"修改成功",null);
    }
    @PostMapping("/changePassword")
    public Result changePassword(@RequestHeader String adminToken,@RequestBody Account account){
        if(adminService.changePassword(adminToken,account)){
            return new Result(200,"修改成功",null);
        }else {
            return new Result(200,"原密码错误成功",null);
        }
    }
}
